<?php

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
#	FILE:			includes/init.php
#	FUNCTION:		Page initialisation
#	AUTHOR:			Cameron Morrow
#	CREATED:		26/07/2005
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# P H P   S E T T I N G S
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# Report all errors
error_reporting(E_ALL);

# Start session
session_start();

# Use this for IE to remember form data correctly
header("Cache-control: private");


# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# F E E D B A C K
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# Messages Array
$MESSAGE_ARRAY = array();

# Error Array
$ERROR_ARRAY = array();

# SQL Commands Array
$SQL_ARRAY = array();


# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# D A T A B A S E   C O N N E C T I O N
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# Attempt to establish connection
establishDatabaseConnection();

# Determine page ID
$PAGE_ID = substr($SCRIPT_NAME, strrpos($SCRIPT_NAME, "/") + 1);
$PAGE_ID = substr($PAGE_ID, 0, strrpos($PAGE_ID, "."));


# Determine site ID
$SITE_ID = substr($SCRIPT_NAME, 0, strrpos($SCRIPT_NAME, "/"));
$SITE_ID = substr($SITE_ID, strrpos($SITE_ID, "/") + 1);


# Create Pages object and provide with basic details of all pages
$PAGES = PageData::getAllPages();

# Get full data about current page
$PAGE = PageData::getPageDetails($PAGE_ID);

# Initialise User
$USER = new User();

# Page name
$PAGE_NAME = $PAGE -> getData("p_name");

# Is page compact
$PAGE_COMPACT = ($PAGE -> getData("p_popup") == "1");

# Page Content
$PAGE_CONTENT = "";

# Get mode from POST
$PAGE_MODE = (@$_POST["mode"]) ? (string) $_POST["mode"] : "";

# Get ID from POST
$PASSED_ID = (@$_POST["id"]) ? removeInvalidChars(strtolower($_POST["id"]), $VALID_CHAR_LIST["ids"]) : "";

# Get Search from POST
$SEARCH_TERM = (@$_POST["search"]) ? removeInvalidChars(strtolower($_POST["search"]), $VALID_CHAR_LIST["idsspaces"]) : "";

# Get Search Filter Value from POST
$SEARCH_FILTER = (@$_POST["filter"]) ? removeInvalidChars(strtolower($_POST["filter"]), $VALID_CHAR_LIST["names"]) : "";

# Authorized to view page?
$IS_AUTHORIZED = false;

# Authorization Message is the message to display
$AUTHORIZATION_MESSAGE = "<p>Please enter your user ID and password to continue.</p>";

# Instantiate Cart
$CART = new Cart();


?>